define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'yeemanage/yee/index' + location.search,
                    add_url: 'yeemanage/yee/add',
                    edit_url: 'yeemanage/yee/edit',
                    del_url: 'yeemanage/yee/del',
                    multi_url: 'yeemanage/yee/multi',
                    import_url: 'yeemanage/yee/import',
                    table: 'yee',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'store_no', title: __('门店编号'), operate: 'LIKE'},
                        {field: 'requestNo', title: __('Requestno'), operate: 'LIKE'},
                        {field: 'merchantNo', title: __('Merchantno')},
                        {field: 'businessRole', title: __('Businessrole'), searchList: {"SHARE_MERCHANT":__('分账接收方'),"SETTLED_MERCHANT":__('入驻商户'),"PLATFORM_MERCHANT":__('平台商'),"ORDINARY_MERCHANT":__('标准商户')}, formatter: Table.api.formatter.normal},
                        {field: 'signName', title: __('Signname'), operate: 'LIKE'},
                        {field: 'signType', title: __('Signtype'), searchList: {"COMMUNITY":__('社会团体'),"INSTITUTION":__('事业单位'),"ENTERPRISE":__('企业'),"INDIVIDUAL":__('个体工商户')}, formatter: Table.api.formatter.normal},
                        {field: 'licenceNo', title: __('Licenceno'), operate: 'LIKE'},
//                      {field: 'licenceUrlimage', title: __('Licenceurlimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'shortName', title: __('Shortname'), operate: 'LIKE'},
//                      {field: 'openAccountLicenceUrlimage', title: __('Openaccountlicenceurlimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
//                      {field: 'handLicenceUrlimage', title: __('Handlicenceurlimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'legalName', title: __('Legalname'), operate: 'LIKE'},
                        {field: 'legalLicenceType', title: __('Legallicencetype'), searchList: {"OFFICERS":__('Officers'),"SOLDIER":__('Soldier'),"TAIWAN":__('Taiwan'),"HM_VISITORPASS":__('Hm_visitorpass'),"PASSPORT":__('Passport'),"ID_CARD":__('Id_card')}, formatter: Table.api.formatter.normal},
                        {field: 'legalLicenceNo', title: __('Legallicenceno'), operate: 'LIKE'},
//                      {field: 'legalLicenceFrontUrlimage', title: __('Legallicencefronturlimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
//                      {field: 'legalLicenceBackUrlimage', title: __('Legallicencebackurlimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'contactName', title: __('Contactname'), operate: 'LIKE'},
                        {field: 'contactMobile', title: __('Contactmobile'), operate: 'LIKE'},
//                      {field: 'contactEmail', title: __('Contactemail'), operate: 'LIKE'},
//                      {field: 'contactLicenceNo', title: __('Contactlicenceno'), operate: 'LIKE'},
//                      {field: 'servicePhone', title: __('Servicephone'), operate: 'LIKE'},
//                      {field: 'primaryIndustryCategory', title: __('Primaryindustrycategory'), operate: 'LIKE'},
//                      {field: 'secondaryIndustryCategory', title: __('Secondaryindustrycategory'), operate: 'LIKE'},
//                      {field: 'province', title: __('Province'), operate: 'LIKE'},
//                      {field: 'city', title: __('City'), operate: 'LIKE'},
//                      {field: 'district', title: __('District'), operate: 'LIKE'},
//                      {field: 'address', title: __('Address'), operate: 'LIKE'},
//                      {field: 'settlementDirection', title: __('Settlementdirection'), searchList: {"BANKCARD":__('Bankcard'),"ACCOUNT":__('Account')}, formatter: Table.api.formatter.normal},
//                      {field: 'bankAccountType', title: __('Bankaccounttype'), searchList: {"ENTERPRISE_ACCOUNT":__('对公账户'),"UNIT_SETTLEMENT_CARD":__('单位结算卡')}, formatter: Table.api.formatter.normal},
//                      {field: 'bankCardNo', title: __('Bankcardno'), operate: 'LIKE'},
//                      {field: 'bankCode', title: __('Bankcode'), operate: 'LIKE'},
//                      {field: 'notifyUrl', title: __('Notifyurl'), operate: 'LIKE', formatter: Table.api.formatter.url},
                        {field: 'applicationStatus', title: __('Applicationstatus'), searchList: {"COMPLETED":__('申请已完成'),"BUSINESS_OPENING":__('业务开通中'),"AGREEMENT_SIGNING":__('协议待签署'),"REVIEW_BACK":__('申请已驳回'),"REVIEWING":__('申请审核中')}, formatter: Table.api.formatter.status},
                        {field: 'applicationNo', title: __('Applicationno'), operate: 'LIKE'},
                        {field: 'agreementSignUrl', title: __('签署文件地址'), operate: 'LIKE'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,buttons: [{
                                
					            name: 'ajax',
						            text: __('提交商户资料'),
						            title: __('提交商户资料'),
						            classname: 'btn btn-xs btn-success btn-magic btn-ajax',
						            icon: 'fa fa-magic',
						            url: 'yeemanage/yee/submitdata',
						            confirm: '确认提交',
						            success: function (data, ret) {
						                Layer.alert(ret.msg + ",返回数据：" + JSON.stringify(data));
						                //如果需要阻止成功提示，则必须使用return false;
						                //return false;
						            },
						            error: function (data, ret) {
						                console.log(data, ret);
						                Layer.alert(ret.msg);
						                return false;
						            }


                            },
                            {
                                
					            name: 'ajax',
						            text: __('产品变更'),
						            title: __('产品变更'),
						            classname: 'btn btn-xs btn-success btn-magic btn-ajax',
						            icon: 'fa fa-magic',
						            url: 'yeemanage/yee/submitchangedata',
						            confirm: '确认提交',
						            success: function (data, ret) {
						                Layer.alert(ret.msg + ",返回数据：" + JSON.stringify(data));
						                //如果需要阻止成功提示，则必须使用return false;
						                //return false;
						            },
						            error: function (data, ret) {
						                console.log(data, ret);
						                Layer.alert(ret.msg);
						                return false;
						            }


                            },
                            {
                                
					            name: 'ajax',
						            text: __('小程序配置'),
						            title: __('小程序配置'),
						            classname: 'btn btn-xs btn-success btn-magic btn-ajax',
						            icon: 'fa fa-magic',
						            url: 'yeemanage/yee/smalldata',
						            confirm: '确认提交',
						            success: function (data, ret) {
						                Layer.alert(ret.msg + ",返回数据：" + JSON.stringify(data));
						                //如果需要阻止成功提示，则必须使用return false;
						                //return false;
						            },
						            error: function (data, ret) {
						                console.log(data, ret);
						                Layer.alert(ret.msg);
						                return false;
						            }


                            }], formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
